package com.yuexun.beilunpatient.ui.my.presenter.impl;

import com.yuexun.beilunpatient.ui.bean.BaseListEntity;
import com.yuexun.beilunpatient.ui.my.model.ILoginOutModel;
import com.yuexun.beilunpatient.ui.my.presenter.ILoginOutPresenter;
import com.yuexun.beilunpatient.ui.my.ui.view.ILoginOutView;

import org.kymjs.kjframe.ui.ViewInject;

import java.util.Map;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by chenss on 2018/3/14 0014.
 */

public class LoginOutPresenter implements ILoginOutPresenter {

    private ILoginOutView view;
    private ILoginOutModel model;

    //记录Log
//    private final Logger log = ProUtil.getLogger(LoginPresneter.class);

    public LoginOutPresenter(ILoginOutModel model, ILoginOutView view) {
        this.model = model;
        this.view = view;
    }

    @Override
    public void outLogin(Map<String, String> praise) {
        model.outLogin(praise)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<BaseListEntity>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        ViewInject.toast("登录失败");
                    }

                    @Override
                    public void onNext(BaseListEntity loginBean) {
                        view.outLogin(loginBean);
                    }
                });
    }
}
